dplyr : data manipulationLoad tidyverse:
library( tidyverse )
survey dataLoad the survey data in tibble format and inspect the meta information such as dimensions and column (variable) types.
class, str, glimpse (tidyverse) functions.
str and glimpse output?Produce the following values on survey data by using the pipe operator %>%:
Apply the following to survey data:
Rename the m.i variable into system
Reorder the variables as such that name,age and gender come first
Select the last three variables
Deselect variables that relate to hand and/or arm (e.g. *.hnd, etc.)
Summary values survey data:
Retrieve distinct values for smoking habit (smokes), do the same for exercise pattern exercise.
Derive the frequency (count) table of smoking, do the same for exercise pattern.
Derive the frequency (count) table of smoking and exercise pattern.
How many females are there who never smoked?
How many right-handed heavy smokers are there, counts per gender?
Select teenagers.
What are the counts of smoking habits (smokes) in teenagers?
What are the counts of exercise patterns (exercise) in teenagers?
Add a new column feet with heights reported in feet unit (1 foot = 30.48 cm).
Add a new column ‘diffHandSpan’ : the absolute difference in span of writing hand span1 and non-writing hand span2.
Count the number of students with smaller writing hand span.
Summary (summarise)
In survey data summarise on:
mean age along with total count
mean writing and non-writing hand span (span1,span2) .
mean, minimum and maximum feet (height)
Group (group_by)
gender
smoking habit
gender and smoking habit
exercise pattern
gender and exercise pattern
Sort (arrange)
Order the survey data by:
name
gender and name
name and gender
gender,name and smoking habit
descending order of gender, name and descending order of height
average height
minimum and maximum writing hand span span1
minimum and maximum non-writing hand span span2
reportedHeight with heights reported by the student in the original unit (system or m.i). Assume inch in case of imperial (1 inch = 2.54 cm) . Hint: use ifelse to test for the system used.Copyright © 2020 Biomedical Data Sciences | LUMC